package com.atan.weblog.web.controller;

import com.atan.weblog.common.aop.ApiOperationLog;
import com.atan.weblog.common.utils.ResponseUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/admin/test")
@Api(tags = "测试接口")
@Slf4j
public class testController {

    @GetMapping("/a")
    @ApiOperation("测试")
    public ResponseUtil test(){
        System.out.println("false = " + false);
        return ResponseUtil.fail();
    }

    @PostMapping("/update")
    @ApiOperationLog(description = "测试更新接口")
    @ApiOperation(value = "测试更新接口")
    @PreAuthorize("hasRole('ROLE_ADMIN')")
    public ResponseUtil testUpdate() {
        log.info("更新成功...");
        return ResponseUtil.success();
    }
}
